package org.rcgwt.client.ui.validator.impl;

import org.rcgwt.client.ui.validator.IClientValidatorContext;
import org.rcgwt.client.ui.validator.IConverter;
import org.rcgwt.client.ui.validator.ISingleton;
import org.rcgwt.client.ui.validator.IValidatorElement;

import com.google.gwt.user.client.ui.Widget;

/**
 * A Double converter. It can return a object representation of a string.
 * 
 * @author Elian
 * 
 * @param <T>
 *            The returned object type
 */

public class DoubleConverter implements IConverter<Double>, ISingleton {

	private static final DoubleConverter INSTANCE = new DoubleConverter();

	protected DoubleConverter() {

	}

	@Override
	public Double getAsObject(IClientValidatorContext context,
			Widget component, String value) {
		return Double.valueOf(value);
	}

	@Override
	public String getAsString(IClientValidatorContext context,
			Widget component, Double value) {
		return value.toString();
	}

	public static IValidatorElement getInstance() {
		return INSTANCE;
	}
}
